﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;

namespace TBG.TBG_F
{
    enum TileStates
    {
        Passable,
        Blocked
    }

    class Tile
    {
        #region Initialization
        //public Texture2D _texture;
        public Point _Position;
        public int _Width = 48;
        public int _Height = 48;
        public TileStates _State;
        #endregion

        #region Constructor
        //Created based on square location and setted to Passable
        public Tile(int squareX, int squareY)
        {
            _Position = new Point(squareX, squareY);
            _State = TileStates.Passable;
        }
        #endregion

        #region Draw helper methods
        public Rectangle getBoundingRect()
        {
            return new Rectangle((1+_Width) * _Position.X,(1+_Height) * _Position.Y, _Width, _Height);
        }

        //Our top tile is blocked returns OK mark if not returns normal grass
        public Rectangle getSourceRect()
        {
            //checks if tileState is blocked
            if (_State == TileStates.Blocked)
            {
                return new Rectangle(_Width, 0, _Width, _Height);
            }
            else
            {
                return new Rectangle(0, 0, _Width, _Height);
            }
        }

        //needed in cases we want to draw samething on top of the tile
        public Rectangle getSourceRectBackground()
        {
            return new Rectangle(0, 0, _Width, _Height);
        }
        #endregion

        #region Helper methods
        public List<Point> selectedPoint()
        {
            List<Point> list = new List<Point>();
            list.Add(_Position);
            list.Add(new Point(_Position.X - 1, _Position.Y));
            list.Add(new Point(_Position.X + 1, _Position.Y));
            list.Add(new Point(_Position.X, _Position.Y - 1));
            list.Add(new Point(_Position.X, _Position.Y + 1));

            return list;
        }
        #endregion

    }
}
